package com.alvin.springshiro.schedual;

import lombok.extern.log4j.Log4j2;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.stereotype.Component;

import java.util.Calendar;

@Component
@Log4j2
public class SchedualBean {

//    @Bean
    public TaskScheduler alvinTaskScheduler(){
        ThreadPoolTaskScheduler alvinTaskScheduler = new ThreadPoolTaskScheduler();
        alvinTaskScheduler.setPoolSize(10);
        return alvinTaskScheduler;
    }

//    @Async
    @Scheduled(fixedDelay = 2000)
    public void printSchedualString(){
        log.info("计划任务打印字符串:" + Calendar.getInstance().getTime().toString());
    }
}
